package wicresoft.controller.expertInfo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import util.JsonUtil;
import wicresoft.controller.common.BaseController;
import wicresoft.controller.common.Properties;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/16.
 */
@Controller
@RequestMapping("httpPage")
public class ExpertInfoController extends BaseController {




    @RequestMapping(value = "expertInfoDlg")
    public String expertInfoDlg(String idCard, Map map) {
        map.put("idCard", idCard);
        return "expertInfo/expertInfoDlg";

    }


    @RequestMapping(value = "expertBase")
    public String expertBase(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("baseInfo", 1);
        Map<String, Map> result;
        result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        if (!"zj001".equals(result.get("code"))) {
            map.put("errorMessage", result.get("message"));
            return "admin/common/errorPage";
        }
        map.put("baseInfo", result.get("data").get("baseInfo"));
        return "expertInfo/expertBase";
    }

    @RequestMapping(value = "expertCompany")
    public String expertCompany(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("company", 1);
        Map<String, Map> result;
        result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        if (!"zj001".equals(result.get("code"))) {
            map.put("errorMessage", result.get("message"));
            return "admin/common/errorPage";
        }
        map.put("company", result.get("data").get("company"));
        return "expertInfo/expertCompany";
    }

    @RequestMapping(value = "expertMajors")
    public String expertMajors(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("major", 1);
        Map<String,Map> result = (Map) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        if (!"zj001".equals(result.get("code"))) {
            map.put("errorMessage", result.get("message"));
            return "admin/common/errorPage";
        }
        map.put("major",JsonUtil.obj2Json(result.get("data").get("major")) );
        return "expertInfo/expertMajor";
    }

    @RequestMapping(value = "expertCertificate")
    public String expertCertificateGet(String idCard, Map map) {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("certificate", 1);
        try {
            Map<String, Map> result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
            map.put("data", JsonUtil.obj2Json(result.get("data").get("certificate")));
        } catch (Exception e) {
            log.warn("【Manual】=>{}", e.getMessage());
            return "admin/common/errorPage";
        }
        return "expertInfo/expertCertificate";
    }

    @RequestMapping(value = "expertEducationalExperience")
    public String expertEducationalExperienceGet(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("education", 1);
        Map<String, Map> result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        map.put("data", JsonUtil.obj2Json(result.get("data").get("education")));
        return "expertInfo/expertEducation";
    }

    @RequestMapping(value = "expertWorkExperience")
    public String expertWorkExperienceGet(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("work", 1);
        Map<String, Map> result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        map.put("data", JsonUtil.obj2Json(result.get("data").get("work")));

        return "expertInfo/expertWork";
    }

    @RequestMapping(value = "expertTrainingExperience")
    public String expertTrainingExperienceGet(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("train", 1);
        Map<String, Map> result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        map.put("data", JsonUtil.obj2Json(result.get("data").get("train")));
        return "expertInfo/expertTrain";
    }

    @RequestMapping(value = "expertReviewExperience")
    public String expertReviewExperienceGet(String idCard, Map map) throws Exception {
        Map data = new HashMap();
        data.put("idCard", idCard);
        data.put("review", 1);
        Map<String, Map> result = (Map<String, Map>) JsonUtil.json2Obj(Properties.sendData(Properties.getExpertDetailInfo, data, Properties.uid, Properties.key), Map.class);
        map.put("data", JsonUtil.obj2Json(result.get("data").get("review")));
        return "expertInfo/expertReview";
    }


}
